/**
 * 项目实体
 */
export interface Project {
  id: string;
  name: string;
  description?: string;
  ownerId: string;
  collaborators?: Collaborator[];
  createdAt: Date | string;
  updatedAt: Date | string;
  duration: number;
  frameRate: number;
  resolution: Resolution;
  thumbnail?: string;
  status: string;
  visibility: string;
  tags?: string[];
  characters: Character[];
  scenes: Scene[];
  timeline: Timeline;
  audioTracks?: AudioTrack[];
  version: number;
  isTemplate: boolean;
  views: number;
  likes: number;
  comments: number;
  localPath?: string;
  cloudSyncStatus?: string;
  lastExportedAt?: Date | string;
}

/**
 * 分辨率
 */
export interface Resolution {
  width: number;
  height: number;
  aspectRatio: string;
}

/**
 * 协作者
 */
export interface Collaborator {
  userId: string;
  role: string;
  joinedAt: Date | string;
  invitedBy: string;
  status: string;
  permissions: string[];
}

/**
 * 项目版本
 */
export interface ProjectVersion {
  id: string;
  projectId: string;
  versionNumber: number;
  createdAt: Date | string;
  createdBy: string;
  snapshot: string;
  comment?: string;
  size: number;
  isAutosave: boolean;
}

/**
 * 角色
 */
export interface Character {
  id: string;
  name: string;
  projectId: string;
  createdAt: Date | string;
  updatedAt: Date | string;
  parts: CharacterPart[];
  skeleton: Skeleton;
  defaultPose?: Pose;
  expressions?: Expression[];
  properties?: Record<string, any>;
  thumbnail?: string;
  zIndex: number;
  visible: boolean;
  locked: boolean;
  tags?: string[];
  sourceAssetId?: string;
  physicsEnabled: boolean;
  collisionBounds?: CollisionBound[];
}

/**
 * 角色部件
 */
export interface CharacterPart {
  id: string;
  characterId: string;
  type: string;
  name: string;
  imageUrl: string;
  position: Vector2;
  rotation: number;
  scale: Vector2;
  pivot: Vector2;
  zIndex: number;
  visible: boolean;
  opacity: number;
  blendMode?: string;
  attachedTo?: string;
  flipX: boolean;
  flipY: boolean;
  colorAdjustments?: ColorAdjustment;
  filters?: Filter[];
}

/**
 * 骨骼系统
 */
export interface Skeleton {
  id: string;
  characterId: string;
  bones: Bone[];
  rootBoneId: string;
}

/**
 * 骨骼
 */
export interface Bone {
  id: string;
  name: string;
  parentId?: string;
  position: Vector2;
  rotation: number;
  length: number;
  constraints?: BoneConstraint;
  attachedParts?: string[];
}

/**
 * 骨骼约束
 */
export interface BoneConstraint {
  rotationMin?: number;
  rotationMax?: number;
  positionMin?: Vector2;
  positionMax?: Vector2;
  stiffness?: number;
  damping?: number;
}

/**
 * 姿势
 */
export interface Pose {
  id: string;
  name: string;
  characterId: string;
  boneTransforms: BoneTransform[];
  thumbnail?: string;
  tags?: string[];
  category?: string;
}

/**
 * 骨骼变换
 */
export interface BoneTransform {
  boneId: string;
  position: Vector2;
  rotation: number;
}

/**
 * 表情
 */
export interface Expression {
  id: string;
  name: string;
  characterId: string;
  partOverrides: PartOverride[];
  thumbnail?: string;
  category?: string;
}

/**
 * 部件覆盖
 */
export interface PartOverride {
  partId: string;
  imageUrl?: string;
  position?: Vector2;
  rotation?: number;
  scale?: Vector2;
}

/**
 * 场景
 */
export interface Scene {
  id: string;
  name: string;
  projectId: string;
  createdAt: Date | string;
  updatedAt: Date | string;
  duration: number;
  layers: SceneLayer[];
  background?: Background;
  effects?: Effect[];
  thumbnail?: string;
  startTime: number;
  transition?: Transition;
  properties?: Record<string, any>;
  audioTracks?: SceneAudioTrack[];
  visible: boolean;
  locked: boolean;
}

/**
 * 场景图层
 */
export interface SceneLayer {
  id: string;
  sceneId: string;
  name: string;
  type: string;
  zIndex: number;
  visible: boolean;
  locked: boolean;
  opacity: number;
  blendMode?: string;
  mask?: string;
  content: LayerContent;
  effects?: Effect[];
  transform: Transform;
  clipToParent: boolean;
  parentId?: string;
}

/**
 * 图层内容
 */
export interface LayerContent {
  type: string;
  data: any;
}

/**
 * 背景
 */
export interface Background {
  type: string;
  color?: string;
  imageUrl?: string;
  gradient?: Gradient;
  repeat?: string;
  size?: string;
  position?: string;
}

/**
 * 渐变
 */
export interface Gradient {
  type: string;
  angle?: number;
  stops: GradientStop[];
}

/**
 * 渐变节点
 */
export interface GradientStop {
  color: string;
  position: number;
}

/**
 * 转场效果
 */
export interface Transition {
  id: string;
  type: string;
  duration: number;
  direction?: string;
  easing?: string;
  params?: Record<string, any>;
}

/**
 * 特效
 */
export interface Effect {
  id: string;
  type: string;
  name: string;
  enabled: boolean;
  params: Record<string, any>;
  keyframes?: EffectKeyframe[];
}

/**
 * 特效关键帧
 */
export interface EffectKeyframe {
  time: number;
  value: any;
  easing?: string;
}

/**
 * 时间轴
 */
export interface Timeline {
  id: string;
  projectId: string;
  duration: number;
  tracks: Track[];
  markers?: TimelineMarker[];
  currentTime: number;
}

/**
 * 轨道
 */
export interface Track {
  id: string;
  name: string;
  type: string;
  targetId: string;
  visible: boolean;
  locked: boolean;
  keyframes: Keyframe[];
  color?: string;
  height?: number;
  collapsed: boolean;
  parentId?: string;
  order: number;
}

/**
 * 关键帧
 */
export interface Keyframe {
  id: string;
  trackId: string;
  time: number;
  value: any;
  easing?: string;
  selected: boolean;
  type?: string;
  interpolation: string;
  bezierHandles?: BezierHandles;
}

/**
 * 贝塞尔控制点
 */
export interface BezierHandles {
  inHandle: Vector2;
  outHandle: Vector2;
}

/**
 * 时间轴标记
 */
export interface TimelineMarker {
  id: string;
  name: string;
  time: number;
  color?: string;
  note?: string;
  type?: string;
}

/**
 * 音频轨道
 */
export interface AudioTrack {
  id: string;
  projectId: string;
  name: string;
  clips: AudioClip[];
  volume: number;
  muted: boolean;
  solo: boolean;
  color?: string;
  order: number;
}

/**
 * 场景音频轨道
 */
export interface SceneAudioTrack {
  id: string;
  sceneId: string;
  name: string;
  clips: AudioClip[];
  volume: number;
  muted: boolean;
}

/**
 * 音频片段
 */
export interface AudioClip {
  id: string;
  trackId: string;
  audioUrl: string;
  name: string;
  startTime: number;
  duration: number;
  volume: number;
  fadeIn?: number;
  fadeOut?: number;
  trimStart?: number;
  trimEnd?: number;
  waveformData?: number[];
  effects?: AudioEffect[];
}

/**
 * 音频效果
 */
export interface AudioEffect {
  id: string;
  type: string;
  name: string;
  enabled: boolean;
  params: Record<string, any>;
}

/**
 * 二维向量
 */
export interface Vector2 {
  x: number;
  y: number;
}

/**
 * 矩形
 */
export interface Rect {
  x: number;
  y: number;
  width: number;
  height: number;
}

/**
 * 变换
 */
export interface Transform {
  position: Vector2;
  rotation: number;
  scale: Vector2;
  pivot: Vector2;
}

/**
 * 颜色调整
 */
export interface ColorAdjustment {
  brightness?: number;
  contrast?: number;
  saturation?: number;
  hue?: number;
  tint?: string;
  gamma?: number;
}

/**
 * 滤镜
 */
export interface Filter {
  type: string;
  enabled: boolean;
  params: Record<string, any>;
}

/**
 * 碰撞边界
 */
export interface CollisionBound {
  type: string;
  points?: Vector2[];
  center?: Vector2;
  radius?: number;
  rect?: Rect;
}

/**
 * 项目响应
 */
export interface ProjectResponse {
  success: boolean;
  project?: Project;
  message?: string;
}

/**
 * 项目列表响应
 */
export interface ProjectListResponse {
  success: boolean;
  projects?: Project[];
  message?: string;
}

/**
 * 场景响应
 */
export interface SceneResponse {
  success: boolean;
  scene?: Scene;
  message?: string;
}

/**
 * 角色响应
 */
export interface CharacterResponse {
  success: boolean;
  character?: Character;
  message?: string;
}

/**
 * 导出项目响应
 */
export interface ExportProjectResponse {
  success: boolean;
  filePath?: string;
  message?: string;
} 